#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/eventfd.h>
//返回值：事件次数

int main()
{
    int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
    if(efd < 0)
    {
        perror("eventfd failed!!");
        return -1;
    }
        uint64_t val = 1;//必须8字节
        write(efd, &val, sizeof(val));
        write(efd, &val, sizeof(val));
        write(efd, &val, sizeof(val));
        uint64_t res = 0;
        read(efd, &res, sizeof(res));
        printf("%d\n", res);
        close(efd);
        return 0;
}